<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/webwork" prefix="ww"%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>Check Out</title>
  </head>
  <body>
  <%@ include file="/shopping-header.html" %>
  <h3>Cart Contents</h3><ww:if test="hasActionErrors()">
      <ul>
        <ww:iterator value="actionErrors">
          <li style="color: red;">
            <ww:property/>
          </li>
        </ww:iterator>
      </ul>
    </ww:if>
    
    <!-- if statement is a workaround for stack overflow bug -->
    <ww:if test="1==1">
    <%@ include file="cart.jsp" %>
    </ww:if>
      <p>
        &nbsp;
      </p>
      <ww:form action="Confirmation.action" method="post">
        First Name:
        <ww:textfield name="fName" value="%{fName}"/>
        Last Name:
        <ww:textfield name="lName" value="%{lName}"/>
        <p>
          &nbsp;
        </p>
        Address 1:
        <ww:textfield name="address1" value="%{address1}"/>
        Address 2:
        <ww:textfield name="address2" value="%{address2}"/>
        <p>
          &nbsp;
        </p>
        City:
        <ww:textfield name="city" value="%{city}"/>
        State:
        <ww:select
          name="state"
          value="state"
          list="usStates"
          listKey="abbreviation"
          listValue="abbreviation + \" - \" + name"
          required="true"
          cssStyle="width: 55px"
        />
        Zipcode:
        <ww:textfield name="zip" value="%{zip}" maxlength="5"/>
        <p>
          &nbsp;
        </p>
        Phone #:
        <ww:textfield name="phone" value="%{phone}" maxlength="15"/>
        <p>
          &nbsp;
        </p>
        <ww:if test="creditCardsListSize > 0)">
          Credit Card processing not available at this time.  You will be billed by mail.
        </ww:if>
        <ww:else>
          CC Type (Choose One)
          
          <ww:select label="'Credit Cards'"
              name="ccType"
              list="validCreditCardsList"
              listKey="id"
              listValue="name"              
              required="true"
              />
<%--            <ww:textfield name="ccType" value="%{ccType}"/> --%>

        </ww:else>
        CC #:
        <ww:textfield name="ccNumber" value="%{ccNumber}" maxlength="20"/>
        <p>
          &nbsp;
        </p>
        Security Code (XYZ)
        <ww:textfield name="ccSecurity" value="%{ccSecurity}" maxlength="4"/>
        Expiration (MMYY)
        <ww:textfield name="ccExpiration" value="%{ccExpiration}" maxlength="5"/>
        <p>
        <h3>Choose Shipping Option:</h3>
        <ww:if test="calculatedShippingOptionsList.size > 0">
          <table border="1">
            <tr>
              <th>Select Option</th>
              <th>Company</th>
              <th>Service</th>
              <th>Delivery Time</th>
              <th>Cost</th>
              <th>Total Cart Price</th>
            </tr>
            <%-- pure HTML Implementation --%>

            <ww:iterator value="calculatedShippingOptionsList">
              <tr>
                <td align="center">
                <%-- <ww:radio label="'Shipping Options'" list="calculatedShippingOptionsList" />
                --%>
                <input type="radio" name="chosenShippingOption" value="<ww:property value="shippingOption.id"/>" <ww:if test="chosenShippingOption == shippingOption.id">checked</ww:if>>
                </td>
                <td><ww:property value="shippingOption.companyName" /></td>
                <td><ww:property value="shippingOption.serviceName" /></td>
                <td align="right"><ww:property value="shippingOption.time" /></td>
                <td align="right">$<ww:property value="cost" /></td>
                <td align="right">$<ww:property value="cost + cart.totalPrice" /></td>
              </tr>
            </ww:iterator>
            
          </table>
        </ww:if>
    
        <p>
        <ww:submit value="Submit order"/>
      </ww:form>
    
    
    
    </body>
</html>